<template>
    <ynet-content id="requestPin" :headerInformation="true" :headerMenu="true" class="main-container">
        <div ><!--提示当前位置  电话银行账户状态维护-->
			<ynet-breadcrumb></ynet-breadcrumb>
		</div>
        <div  v-if="main">
            <div class="fourForm tableForm mt20 tableData">
                <el-table :data="authInfoList" border>
                    <el-table-column label="Transaction Sequence No." prop="flowNo">
                        <template scope="scope">
                        <span><a class="cOrange" @click="queryDetail(Number(scope.$index))">{{scope.row.flowNo}}</a></span>
                    </template>
                    </el-table-column>
                    <el-table-column label="Transaction Date Time" prop="submitTime" >
                        <template scope="scope">
                            {{$tools.utils.formatDateSymbol(scope.row.submitTime)}}
                         </template>
                    </el-table-column>
                 <!--   <el-table-column label="TBS A/C No" prop="TBSNo"></el-table-column>  -->
                    <el-table-column label="Checker ID" prop="userNo"></el-table-column>
                 <!--   <el-table-column label="Remark" prop="remark"></el-table-column>   -->
                    <el-table-column label="Operation">
                        <template scope="scope">
                            <span><a class="cOrange" @click="editAuthInfo(Number(scope.$index))">modify</a></span>
                            <span><a class="cOrange" @click="deleteConfirm(Number(scope.$index))">delete</a></span>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="pagination mt30 tac" v-if="totalsize>pageSize">
              <el-pagination @current-change="handleCurrentChange" :current-page.sync="currentPage" :page-size="pageSize" layout="prev, pager, next, jumper" :total="totalsize"></el-pagination>
            </div>
        </div>
        
        <div v-if="IM0401">
            <newPhoneAccountEdit :detailData="detailData" @back="back"></newPhoneAccountEdit>
        </div>
        <div v-if="IM0401_detail">
            <newPhoneAccountDetail :toDetailData="toDetailData" @back="back"></newPhoneAccountDetail>
        </div>

        <div v-if="IM040201_detail">
            <addOrHangAccountDetail :toDetailData="toDetailData" @back="back"></addOrHangAccountDetail>
        </div> 

        <div v-if="IM040202">
            <accStateOperEdit :detailData="detailData" @back="back"></accStateOperEdit>
        </div> 
        <div v-if="IM040202_detail">
            <accStateOperDetail :toDetailData="toDetailData" @back="back"></accStateOperDetail>
        </div>

        <!--删除提交确认-->
          <el-dialog :visible.sync="dialogVisible" size=tiny class="money tac">
              <span style="font-size:16px;">Are you sure you want to delete this review ?</span>
              <div slot="footer" class="dialog-footer">
                  <el-button @click="dialogVisible = false">Cancel</el-button>
                  <el-button type="primary" @click="dialogVisible = false;deleteAuthInfo()">Confirm</el-button>
              </div>
          </el-dialog>
       <!--删除提交确认 end--> 
    </ynet-content>
</template>

<script>
    import newPhoneAccountEdit from './components/newPhoneAccount_edit'
    import newPhoneAccountDetail from './components/newPhoneAccount_detail' 

    import addOrHangAccountDetail from './components/addOrHangAccount_detail'   

    import accStateOperEdit from './components/accStateOper_edit'    
    import accStateOperDetail from './components/accStateOper_detail'  

	export default {
		name:'dealModify',
		components:{
            newPhoneAccountEdit,
            newPhoneAccountDetail,
            addOrHangAccountDetail,
            accStateOperEdit,
            accStateOperDetail
		},
		data(){
            return { 
                main:true, 
                dialogVisible:false,
                currentPage:1, 
                totalsize:0,
                pageSize:10,
                authInfoList:[],
                detailData:{},
                toDetailData:{},
                flowNoTemp:'',
                IM0401:false,
                IM0401_detail:false,
                IM040201_detail:false,
                IM040202:false,
                IM040202_detail:false,
            }   
        },
        mounted(){
            this.queryPhoneAuth();
        },
		methods:{ 
            deleteConfirm(index){
               let _this = this
               _this.flowNoTemp = _this.authInfoList[index].flowNo
               _this.dialogVisible = true
            },
            queryPhoneAuth(){
                let _this = this
                let queryData = {}
                queryData.currentPage = _this.currentPage
                queryData.turnPageShowNum = _this.pageSize
                _this.$tools.request(this,'IM080208Action.do',queryData).then(data=>{
                    console.log("待审核信息:"+JSON.stringify(data))
                    if(data.body.errorCode==0){
                        _this.totalsize = data.body.turnPageTotalNum
                        _this.authInfoList = data.body.accoPhoneAuthList;
                       
                    }else{
                        _this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confirm',
                        })
                    }
                        
                })
                
            },
            //查询详情
            queryDetail(index){
                let _this = this
                _this.toDetailData = {}
                var jsonData
                var tempBsnCode
                for(let i = 0; i < _this.authInfoList.length; i++){
                   if(_this.authInfoList[i].flowNo == _this.authInfoList[index].flowNo){
                       tempBsnCode = _this.authInfoList[index].bsnCode
                       console.log("tempBsnCode",tempBsnCode)
                       jsonData = _this.authInfoList[i].newCotent;//json字符串
                       _this.toDetailData = _this.$tools.utils.transferJson(jsonData)
                       console.log("详情页具体:toDetailData:"+JSON.stringify(_this.toDetailData))
                       break;
                   }
               }
               switch(tempBsnCode){
                    case 'IM0401': //角色详情
                        this.IM0401_detail=true;
                        this.main=false;
                        break;
                    case 'IM040201': //角色详情
                        this.IM040201_detail=true;
                        this.main=false;
                        break;
                    case 'IM040202': //角色详情
                        this.IM040202_detail=true;
                        this.main=false;
                        break;
                   
                }
            },
            //删除待审核信息
            deleteAuthInfo(){
                let _this = this
                let queryData = {}
                queryData.flowNo = _this.flowNoTemp
                _this.$tools.request(_this,"IM080210Action.do", queryData).then(
                    data => {
                        if('0' == data.body.errorCode){
                            setTimeout(function(){
                                _this.queryPhoneAuth()
                            },500)
                        }else{
                            _this.$alert("System Error Try again", "warning",{
                                confirmButtonText: 'Confirm',
                            })
                        }
                    }
                )
            },
            //编辑待审核信息
            editAuthInfo(index){
                let _this = this
                _this.detailData = {}
                var jsonData
                var tempBsnCode
                for(let i = 0; i < _this.authInfoList.length; i++){
                   if(_this.authInfoList[i].flowNo == _this.authInfoList[index].flowNo){
                       tempBsnCode = _this.authInfoList[index].bsnCode
                       console.log("tempBsnCode",tempBsnCode)
                       
                       jsonData = _this.authInfoList[i].newCotent;//json字符串
                       console.log("jsonData",jsonData)
                       _this.detailData = _this.$tools.utils.transferJson(jsonData)
                       console.log("详情页具体:detailData:"+JSON.stringify(_this.detailData))
                       break;
                   }
               }
               switch(tempBsnCode){
                    case 'IM0401': //角色详情
                        this.IM0401=true;
                        this.main=false;
                        break;
                    case 'IM040202': //角色详情
                        this.IM040202=true;
                        this.main=false;
                        break;
                }
            },
            
            //翻页1
            handleCurrentChange(value){
                let _this = this
                _this.currentPage = value
                _this.queryPhoneAuth()
            },
            back(){
                this.main=true;
                this.IM0401=false;
                this.IM0401_detail=false;
                this.IM040201=false;
                this.IM040202=false;
                this.IM040201_detail=false;
                this.IM040202_detail=false;
                this.queryPhoneAuth();
                // this.queryCurrentList();
            }

		}
	}
</script>